'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 5_llm_chat_model_use.py
* @Time: 2025/10/22
* @All Rights Reserve By Brtc
'''
from datetime import datetime

import dotenv
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI


dotenv.load_dotenv()
#1、编排prompt
prompt = ChatPromptTemplate.from_messages([
    ("system", "你是OpenAI 研发的机器人， 请回答用户的问题,现在时间是{now}"),
    ("human","{query}")
]).partial(now = datetime.now)

#2、创建大模型
llm = ChatOpenAI(model="gpt-4o-mini")
ai_message = llm.invoke(prompt.invoke({"query":"现在几点钟，并请你讲一个关于程序员的笑话"}))

print(ai_message.type)
print(ai_message.content)
print(ai_message.response_metadata)